// 依赖的第三方库的样式
import 'element-plus/dist/index.css'
import 'vant/lib/index.css'
import 'tippy.js/dist/tippy.css'; // 引入样式

import {createApp} from 'vue'
// import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import Vant from 'vant';
import VueTippy from 'vue-tippy'
import EChartsPlugin from './plugins/echarts.js'

import jzlUtils, * as JzlUtils from '@jzl/utils'
import jzlApi, * as JzlApi from '@jzl/api'
import jzlComps, * as JzlComps from '@jzl/comps'
import jzlCompsMg, * as JzlCompsMg from '@jzl/comps-mg'

import { errorHandler, successHandler } from "@/common/axios-handlers.js";
import { setupStore } from "@/store";
import initPlatformConfig from './config/index.js';

// 兼容开发模式，定义全局变量
import * as Vue from 'vue'
import _ from 'lodash'
// import * as JzlUtils from '@jzl/utils'

// process.env.NODE_ENV,
if(import.meta.env.MODE === 'development') {

  window.Vue = Vue;
  // window._ = _;
  // window.JzlUtils = JzlUtils;
  window.JzlUtils = JzlUtils
  window.JzlApi = JzlApi
  window.JzlComps = JzlComps
  window.JzlCompsMg = JzlCompsMg
}

import App from './App.vue'
import router from './router'

// 自定义样式， 后引入，防止被 comps 中覆盖
import "./views/css/index.scss";
import './views/css/tailwind.css'

const app = createApp(App)

initPlatformConfig(app);

// app.use(createPinia())
setupStore(app)
// app.use(VueCodemirror)
app.use(router)
app.use(EChartsPlugin)
app.use(jzlUtils, {
  clientType: import.meta.env.VITE_CLIENT_TYPE,
})
app.use(jzlApi, {
  baseUrl: import.meta.env.VITE_APP_URL,
  errorHandler,
  successHandler,
  // axios,
  // getToken,
  // getConfig,
})
app.use(jzlComps)
app.use(jzlCompsMg)

app.use(ElementPlus, { locale: zhCn });
app.use(Vant);
app.use(VueTippy, {
  directive: 'tippy', // => v-tippy
  component: 'tippy', // => <tippy/>
  componentSingleton: 'tippy-singleton', // => <tippy-singleton/>,
  defaultProps: {
    // placement: 'auto-end',
    allowHTML: true,
  }
});

app.mount('#app')
